const npminstall = require('npminstall');

 var root = process.cwd()
 npminstall({
   // install root dir
   root,
   // optional packages need to install, default is package.json's dependencies and devDependencies
   pkgs: [
     { name: 'vue', version: '^2.6.0' },
   ],
   // install to specific directory, default to root
   targetDir: './a/lib',
   // link bin to specific directory (for global install)
   binDir: './a/bin',
   // registry, default is https://registry.npmjs.org
   registry: 'https://registry.npmjs.org',
   // debug: false,
   storeDir: root + '/node_modules',
  //  detail: true,
   // ignoreScripts: true, // ignore pre/post install scripts, default is `false`
   // forbiddenLicenses: forbit install packages which used these licenses
 }).then((res)=>{
   console.log(res)
 })